import {Actor, Action} from 'iflux2';
import {OrderType} from '../constant/action-type';
import {Map} from 'immutable';


export default class TradeActor extends  Actor {
    defaultState() {
        return {
            order: Map(),
            taxRate: 0,
            userLogo: ''
        }
    }


    @Action(OrderType.SET_DETAIL)
    setOrder(state, tradeOrder) {
        return state.set('order', tradeOrder)
    }


    @Action(OrderType.SET_USER_LOGO)
    setUserLogo(state, userLogo) {
        return state.set('userLogo', userLogo);
    }


    @Action(OrderType.SET_FIELD_VALUE)
    setOrderField(state, {value, field}) {
        return state.setIn(['order', field], value);
    }


    @Action(OrderType.SET_TAX_RAT)
    setTaxRate(state, taxRate) {
        return state.set('taxRate', taxRate);
    }
}